//
//  CollectionViewCell.m
//  Korea
//
//  Created by 杨东奇 on 15/9/9.
//  Copyright (c) 2015年 KoreaGo. All rights reserved.
//

#import "CollectionViewCell.h"

@implementation CollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backImage = [[UIImageView alloc] init];
//        self.backImage.backgroundColor = [UIColor cyanColor];
        self.backImage.image = [UIImage imageNamed:@"777.png"];
        [self.contentView addSubview:self.backImage];
        
        self.blur = [[UIView alloc] init];
        self.blur.backgroundColor = [UIColor blackColor];
        self.blur.alpha = 0.2;
       

    
        [self.backImage addSubview:self.blur];
        
        self.titleLabel = [[UILabel alloc] init];
//        self.titleLabel.backgroundColor = [UIColor orangeColor];
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:self.titleLabel];
        self.titleLabel.textColor = [UIColor whiteColor];
//        [self.titleLabel addGestureRecognizer:single];
//        [self.titleLabel addGestureRecognizer:longTouch];
//        [single requireGestureRecognizerToFail:longTouch];
        
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes{
    
    CGFloat width = layoutAttributes.frame.size.width;
    CGFloat height = layoutAttributes.frame.size.height;
    
    self.backImage.frame = CGRectMake(0, 0, width, height);
    self.blur.frame = CGRectMake(0, 0, width, height);
    self.titleLabel.frame = CGRectMake(width / 4, height / 2.91, width / 2, 20);
}


//- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//    [super touchesBegan:touches withEvent:event];
//    
//    UIView *view = [self.contentView  viewWithTag:20000];
//    UIView *view2 = [self.contentView viewWithTag:20001];
//    view.hidden = YES;
//    view2.hidden = YES;
//    NSLog(@"began");
//    
//
//    
//}
//- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
//    [super touchesEnded:touches withEvent:event];
//    UIView *view = [self.contentView  viewWithTag:20000];
//    UIView *view2 = [self.contentView viewWithTag:20001];
//    view.hidden = NO;
//    view2.hidden = NO;
//    NSLog(@"end");
//}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
    [super touchesMoved:touches withEvent:event];
    UIView *view = [self.contentView  viewWithTag:20000];
    UIView *view2 = [self.contentView viewWithTag:20001];
    view.hidden = NO;
    view2.hidden = NO;
    NSLog(@"move");
}

@end
